<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('归还设备')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-link-edit" th:object="${rentDeviceLink}">
            <input name="id" th:field="*{id}" type="hidden">
            <input name="rentNumber" th:field="*{rentNumber}" type="hidden">
            <input name="rentId" th:field="*{rentId}" type="hidden">
            <input name="deviceId" th:field="*{deviceId}" type="hidden">
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label is-required">器材类型：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="typeName" th:field="*{typeName}" class="form-control" type="text" readonly required>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label is-required">器材型号：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="modeName" th:field="*{modeName}" class="form-control" type="text" readonly required>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">计划租赁开始日期时间：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <div class="input-group date">-->
<!--                        <input name="planRentStartTime" th:value="${#dates.format(rentDeviceLink.planRentStartTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">实际租赁开始日期时间：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <div class="input-group date">-->
<!--                        <input name="actualRentStartTime" th:value="${#dates.format(rentDeviceLink.actualRentStartTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">计划租赁结束时间：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <div class="input-group date">-->
<!--                        <input name="planRentEndTime" th:value="${#dates.format(rentDeviceLink.planRentEndTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">实际租赁结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="actualRentEndTime" th:value="${#dates.format(rentDeviceLink.actualRentEndTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">计划租赁天数：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="planRentSpan" th:field="*{planRentSpan}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">实际租赁天数：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="actualRentSpan" th:field="*{actualRentSpan}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">备注：</label>
                <div class="col-sm-8">
                    <input name="note" th:field="*{note}" class="form-control" type="text" readonly>
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">状态：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="valid" th:field="*{valid}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/link";
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#form-link-edit").validate({
            focusCleanup: true,
            rules: {
                actualRentEndTime: "required"
            },
            messages: {
                actualRentEndTime: icon + "请选择器材实际归还时间"
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.modal.confirm("确认要归还该设备吗?", function() {
                    config = {
                        url: prefix + "/returnDevice",
                        type: "post",
                        dataType: "json",
                        data: $('#form-link-edit').serialize(),
                        beforeSend: function () {
                            $.modal.loading("正在处理中，请稍后...");
                            $.modal.disable();
                        },
                        success: function(result) {
                            $.modal.alert(result.msg);
                            if (typeof callback == "function") {
                                callback(result);
                            }
                            $.operate.successCallback(result);
                        }
                    };
                    $.ajax(config)
                });
            }
        }

        $("input[name='planRentStartTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='actualRentStartTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='planRentEndTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='actualRentEndTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>